<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>
        var n = prompt("请输入一个数字") - 0
        var result = isZhishu(n)

        function isZhishu(num) {

            if (num % 1 != 0) {
                console.log("请输入一个整数")
                return
            }

            var flag = true

            for (var i = 2; i < num; i++) {
                if (num % i === 0) {
                    flag = false
                    break
                }
            }
            console.log(flag)
            // 因为 flag 是 true 就返回 true
            // falg 是 false 就返回 false
            // return flag
        }

        // var result = isZhishu(n)
        // console.log(result)
    </script>
</body>

</html>